import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
	{
		path: "/",
		name: "index",
		component: () => import("../views/main/index.vue")
	},
    {
		path: "/:pathMatch(.*)*",
		redirect: { name: "index" }
	}
];

const router = createRouter({
	history: createWebHashHistory(process.env.BASE_URL),
	routes
});

// 全局路由守卫
// router.beforeEach((to, form, next) => {
// 	let state = localStorage.getItem("loginState");
// 	if(to.name != "login"){
// 		if(state !== "true"){
// 			next({ name: "login" });
// 		} else {
// 			next();
// 		}
// 	} else {
// 		if(state === "true"){
// 			next({ name: "index" });
// 		} else {
// 			next();
// 		}
// 	}
// });

export default router;
